package com.example.demo.datasource;

import com.alibaba.druid.pool.DruidDataSource;

public class DruidDynamicDataSource extends AbstractDynamicDataSource<DruidDataSource> {
    @Override
    public DruidDataSource createDataSource(String driverClassName, String url, String username, String password) {
        DruidDataSource parent = (DruidDataSource) super.getApplicationContext().getBean(
                DEFAULT_DATASOURCE_KEY);
        DruidDataSource ds = new DruidDataSource();
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        ds.setDriverClassName(driverClassName);
        return ds;
    }
}
